package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.task.Task;
import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.CosplayDetailsEntity;
import com.zw.yzk.kabu.data.network.service.CosplayDetailsService;
import com.zw.yzk.kabu.data.network.task.CosDetailsTask;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2016/12/24.
 */

public class CosplayDetailsRepository extends CommonRepository {

    @Inject
    public CosplayDetailsRepository() {

    }

    @Override
    protected Observable connectServer(Task task) {
        CosplayDetailsService cosplayDetailsService = ServiceGenerator.createService(CosplayDetailsService.class);
        CosDetailsTask cosDetailsTask = (CosDetailsTask) task;

        return cosplayDetailsService.getCosplayDetails(cosDetailsTask.cosId, cosDetailsTask.userId, cosDetailsTask.accessToken);
    }

    @Override
    protected Func1<CosplayDetailsEntity, Observable> getServerData() {
        return new Func1<CosplayDetailsEntity, Observable>() {
            @Override
            public Observable call(CosplayDetailsEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
